package edu.ccit.shudong.controller;


import edu.ccit.shudong.dto.NewCommentDto;
import edu.ccit.shudong.service.NewCommentService;
import edu.ccit.shudong.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/newComments")
@CrossOrigin(origins = "http://localhost:9090", originPatterns = "*", methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT})
public class NewCommentController {

    @Autowired
    private NewCommentService newCommentService;

    /**
     * 获取评论树形列表
     * @param postId
     * @return
     */
    @GetMapping("/list")
    public Object getListWithReplyByPostId(@RequestParam Long postId) {
        List<NewCommentDto> result = newCommentService.getListWithReplyByPostId(postId);
        return R.ok(result);
    }

}
